$(function () {
    // 初始化  简体  美元
    function jianTi(index) {
        $("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.yy>li").eq(index).css({
            "background-color": "#FF406E"
        }).siblings().css({
            "background-color": "rgb(201, 201, 201)"
        });
        $("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.yy>li").eq(index).find("a").css({
            "color": "#fff"
        }).parent().siblings().find("a").css({
            "color": "rgb(107, 107, 107)"
        });
    }
    jianTi(0);

    function MY(index) {
        $("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.jq>li").eq(index).css({
            "background-color": "#FF406E"
        }).siblings().css({
            "background-color": "rgb(201, 201, 201)"
        });
        $("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.jq>li").eq(index).find("a").css({
            "color": "#fff"
        }).parent().siblings().find("a").css({
            "color": "rgb(107, 107, 107)"
        });
    }
    MY(0);
    // 点击语言
    // console.log("测试");
    $("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.yy>li>a").click(function () {
        var code = $(this).html();
        var index = $(this).parents("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.yy>li").index();
        jianTi(index);
        // console.log(index);
        if (code == "简体中文") {
            // console.log("简体");
            $(".headerBGC>.headerTop>.language>ul>li>.j").html("简体");
        };
        if (code == "繁体中文") {
            // console.log("繁体");
            $(".headerBGC>.headerTop>.language>ul>li>.j").html("繁体");
        };
        if (code == "English") {
            // console.log("Eng");
            $(".headerBGC>.headerTop>.language>ul>li>.j").html("Eng");
        };
    });
    // 点击金钱
    $("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.jq>li>a").click(function () {
        var name = $(this).html();
        var reg = /[\u4e00-\u9fa5]/g;
        var names = name.match(reg);
        var index = $(this).parents("body>header>.headerBGC>.headerTop>.language>ul>li>.content>.jq>li").index();
        MY(index);
        name = names.join("");
        console.log(name);
        $(".headerBGC>.headerTop>.language>ul>li>.m").html(name);
    });



    // 点击图片查看详情
    function AddImgClickEvent() {
        var objs = $("body>header>.headerBGC>.headerTop>.loginbar>ul>li>div>img");
        // console.log(objs)
        for (var i = 0; i < objs.length; i++) {
            objs[i].onclick = function () {
                window.open(this.src);
            }
            objs[i].style.cursor = "pointer";
        }
    }
    AddImgClickEvent();



    // 关闭广告
    $("body>header>.banner>span").click(function () {
        console.log("测试");
        $(this).parent().animate({
            opacity: 0,
            height: '0'
        }, 500, function () {
            // Animation complete.
        });

    });

    // 点击nav中的li添加样式
    $("body>header>nav>li").click(function () {
        // console.log($(this));
        $(this).addClass("active").siblings().removeClass("active");
    })
})